﻿<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:Faust_Andrew_MTG_Utilities="clr-namespace:Faust.Andrew.MTG.Utilities;assembly=Faust.Andrew.MTG.Utilities" xmlns:Faust_Andrew_MTG_Player_Shared="clr-namespace:Faust.Andrew.MTG.Player.Shared;assembly=Faust.Andrew.MTG.Player.Shared" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	x:Class="Faust.Andrew.MTG.Player.CounterEditor"
	x:Name="Window"
	Title="Counter Editor"
	Background="{DynamicResource WindowBackground}" Width="600" Height="400" mc:Ignorable="d" Icon="MTGManagerIcon.ico">

	<Window.Resources>
		<Faust_Andrew_MTG_Utilities:IntToStringConverter x:Key="IntToStringConverter"/>
		<Faust_Andrew_MTG_Player_Shared:Counter x:Key="CounterDataSource" d:IsDataSource="True"/>
		<DataTemplate x:Key="CounterItemTemplate">
			<Grid d:DesignWidth="198">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto"/>
					<ColumnDefinition Width="Auto"/>
				</Grid.ColumnDefinitions>
				<Label Margin="0" VerticalAlignment="Stretch" Height="Auto" Content="{Binding Name, Mode=Default}"/>
				<Label Margin="0" Height="Auto" Content="{Binding Value, Mode=Default}" Grid.Column="1"/>
			</Grid>
		</DataTemplate>
	</Window.Resources>

	<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource CounterDataSource}}">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
			<RowDefinition Height="Auto"/>
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="0.514*"/>
			<ColumnDefinition Width="0.486*"/>
		</Grid.ColumnDefinitions>
		<ListBox x:Name="lbCounters" Margin="0" Grid.Row="1" Background="{x:Null}" ItemTemplate="{DynamicResource CounterItemTemplate}"/>
		<StackPanel Margin="0" Grid.Column="1" Grid.Row="1" DataContext="{Binding SelectedItem, ElementName=lbCounters, Mode=OneWay}">
			<Label Content="Name:"/>
			<TextBox x:Name="txtName" Text="{Binding Name, Mode=Default}" TextWrapping="Wrap"/>
			<Label Content="Value"/>
			<TextBox x:Name="txtValue" Text="{Binding Value, Converter={StaticResource IntToStringConverter}, Mode=Default}" TextWrapping="Wrap"/>
		</StackPanel>
		<StackPanel Margin="0" Orientation="Horizontal" HorizontalAlignment="Center">
			<Button x:Name="btnAdd" Margin="0,0,10,0" Content="Add" Width="50" Click="btnAdd_Click"/>
			<Button x:Name="btnDelete" Margin="0" Content="Delete" Width="50" Click="btnDelete_Click"/>
		</StackPanel>
		<StackPanel HorizontalAlignment="Right" Margin="0" Orientation="Horizontal" Grid.Row="2" Grid.Column="1">
			<Button x:Name="btnCancel" Margin="0,0,10,0" Width="50" Content="Cancel" IsCancel="True" Click="btnCancel_Click"/>
			<Button x:Name="btnSave" Margin="0" Width="50" Content="Save" Click="btnSave_Click"/>
		</StackPanel>
	</Grid>
</Window>